class WriteboardsController < ApplicationController
   before_filter :login_required

   def index
    list
    render :action => 'list'
   end

   # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
   verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

   def list
    @writeboard_pages, @writeboards = paginate(:writeboards, :order => 'updated_on DESC', :per_page => 20)
   end

   def show
    @writeboard = Writeboard.find(params[:id])
   end

   def new
    @writeboard = Writeboard.new
   end

   def create
    @writeboard = Writeboard.new(params[:writeboard])
    if @writeboard.save
      flash[:notice] = 'Writeboard was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
   end

   def edit
    @writeboard = Writeboard.find(params[:id])
   end

   def update
    @writeboard = Writeboard.find(params[:id])
    if @writeboard.update_attributes(params[:writeboard])
      flash[:notice] = 'Writeboard was successfully updated.'
      redirect_to :action => 'show', :id => @writeboard
    else
      render :action => 'edit'
    end
   end

   def destroy
    Writeboard.find(params[:id]).destroy
    redirect_to :action => 'list'
   end
end
